<?php 

class store  {



	public function add($parm){
		DB::insert("sysstore",array('province','city','address','contact','longitude','latitude','phone','isget','isstore'))

		->values(array($parm['province'],$parm['city'],$parm['address'],
			$parm['contact'],$parm['longitude'],$parm['latitude'],$parm['phone'],$parm['isget'],$parm['isstore']))->execute();
	}

	
	public function listdata($parm){
		$query = DB::query(Database::SELECT,
	         'select *,(select name from syschina where id=sysstore.province) as provinceshow ,(select name from syschina where id=sysstore.city) as cityshow from sysstore   limit '.($parm['page']-1)*$parm['rows'].','.$parm['rows'])
		->execute()->as_array();
		$count = DB::query(Database::SELECT,
	         'select count(1) from sysstore   ')->execute()->as_array();
		$data['total']=$count[0]['count(1)'];
		$data['rows']=$query;
		return $data;
	}

	public function getListExpress(){
		$result = DB::select('*')->from('sysexpress')->execute()->as_array();
		return $result;
	}
	public function detail($id){
		$query = DB::query(Database::SELECT,
	    'select *,(select name from syschina where id=sysstore.province) as provinceshow ,(select name from syschina where id=sysstore.city) as cityshow from sysstore  where sysstore.id='.$id)
		->execute()->as_array();
		return $query;
	}
	public function update($parm){
		DB::update("sysstore")->set(array('province'=>$parm['province'],'city'=>$parm['city'],'address'=>$parm['address'],
			'contact'=>$parm['contact'],'longitude'=>$parm['longitude'],'latitude'=>$parm['latitude'],'phone'=>$parm['phone'],'isget'=>$parm['isget'],'isstore'=>$parm['isstore']))
		->where('id','=',$parm['id'])->execute();
	}
}